#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    this->setWindowTitle("QQ");
    this->setAttribute(Qt::WA_TranslucentBackground);
    this->setWindowFlag(Qt::FramelessWindowHint);

    QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect(this);
    shadow->setColor(QColor(0,0,0,225));
    shadow->setBlurRadius(30);
    shadow->setOffset(0,0);
    ui->loginwidget->setGraphicsEffect(shadow);
}

MainWindow::~MainWindow()
{
    delete ui;
}


void MainWindow::on_exitPB_clicked()
{
    QApplication::exit();

}
void MainWindow::on_loginPB_clicked()
{
    if(!ui->readRuleRB->isChecked()){
        QMessageBox::information(this,"QQ","请勾选用户协议");
        return;
    }
    if(this->account=="admin"&&password=="123456")
    {
        QMessageBox::information(this,"QQ","登录成功");
        QApplication::exit();
    }
    else{
        QMessageBox::information(this,"QQ","登录失败");
        ui->accountLE->clear();
        ui->passwordLE->clear();
    }
}

void MainWindow::on_registerPB_clicked()
{
    DefaultMessageBox *mb = new DefaultMessageBox(this,"QQ","注册");
    mb->show();
}

void MainWindow::on_accountLE_textChanged(const QString &arg1)
{
    this->account = arg1;
    check_isValid_account_password();
}

void MainWindow::on_passwordLE_textChanged(const QString &arg1)
{
    this->password = arg1;
    check_isValid_account_password();
}
void MainWindow::check_isValid_account_password()
{
    if(this->account.isEmpty()||this->password.isEmpty())
    {
        ui->loginPB->setEnabled(false);
    }
    else{
        ui->loginPB->setEnabled(true);
    }


}

